package com.itlaobing.aop.proxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class Test {

    public static void main(String[] args) {

        Flyable f = new Airplane();

        Class<?> tc = f.getClass();
        ClassLoader loader = tc.getClassLoader();
        Class<?>[] interfaces = tc.getInterfaces();
        InvocationHandler handler = new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                Object result = method.invoke(tc,args);
                return result;
            }
        };

        Object p = Proxy.newProxyInstance(loader, interfaces, handler);
        String s = p.toString() ;
        System.out.println( s );

        System.out.println( f == p ); // false
    }
}
